home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / PropertyChangeEvent.java < prev    next >
Text File  |  1998-09-22  |  3KB  |  102 lines

  1. /*
  2.  * @(#)PropertyChangeEvent.java    1.22 98/07/01
  3.  *
  4.  * Copyright 1996-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.beans;
  16.  
  17. /**
  18.  * A "PropertyChange" event gets delivered whenever a bean changes a "bound"
  19.  * or "constrained" property.  A PropertyChangeEvent object is sent as an
  20.  * argument to the PropertyChangeListener and VetoableChangeListener methods.
  21.  * <P>
  22.  * Normally PropertyChangeEvents are accompanied by the name and the old
  23.  * and new value of the changed property.  If the new value is a builtin
  24.  * type (such as int or boolean) it must be wrapped as the 
  25.  * corresponding java.lang.* Object type (such as Integer or Boolean).
  26.  * <P>
  27.  * Null values may be provided for the old and the new values if their
  28.  * true values are not known.
  29.  * <P>
  30.  * An event source may send a null object as the name to indicate that an
  31.  * arbitrary set of if its properties have changed.  In this case the
  32.  * old and new values should also be null.
  33.  */
  34.  
  35. public class PropertyChangeEvent extends java.util.EventObject {
  36.  
  37.     /**
  38.      * @param source  The bean that fired the event.
  39.      * @param propertyName  The programmatic name of the property
  40.      *        that was changed.
  41.      * @param oldValue  The old value of the property.
  42.      * @param newValue  The new value of the property.
  43.      */
  44.     public PropertyChangeEvent(Object source, String propertyName,
  45.                      Object oldValue, Object newValue) {
  46.     super(source);
  47.     this.propertyName = propertyName;
  48.     this.newValue = newValue;
  49.     this.oldValue = oldValue;
  50.     }
  51.  
  52.     /**
  53.      * @return  The programmatic name of the property that was changed.
  54.      *        May be null if multiple properties have changed.
  55.      */
  56.     public String getPropertyName() {
  57.     return propertyName;
  58.     }
  59.     
  60.     /**
  61.      * @return  The new value for the property, expressed as an Object.
  62.      *        May be null if multiple properties have changed.
  63.      */
  64.     public Object getNewValue() {
  65.     return newValue;
  66.     }
  67.  
  68.     /**
  69.      * @return  The old value for the property, expressed as an Object.
  70.      *        May be null if multiple properties have changed.
  71.      */
  72.     public Object getOldValue() {
  73.     return oldValue;
  74.     }
  75.  
  76.     /**
  77.      * @param propagationId  The propagationId object for the event.
  78.      */
  79.     public void setPropagationId(Object propagationId) {
  80.     this.propagationId = propagationId;
  81.     }
  82.  
  83.     /**
  84.      * The "propagationId" field is reserved for future use.  In Beans 1.0
  85.      * the sole requirement is that if a listener catches a PropertyChangeEvent
  86.      * and then fires a PropertyChangeEvent of its own, then it should
  87.      * make sure that it propagates the propagationId field from its
  88.      * incoming event to its outgoing event.
  89.      *
  90.      * @return the propagationId object associated with a bound/constrained
  91.      *        property update.
  92.      */
  93.     public Object getPropagationId() {
  94.     return propagationId;
  95.     }
  96.  
  97.     private String propertyName;
  98.     private Object newValue;
  99.     private Object oldValue;
  100.     private Object propagationId;
  101. }
  102.